%load lenaqpsk.mat;
Noise = 100;
minx = -6;
maxx = 12;
Numx = 180;
%imshow(imagelenagray);
snrx = linspace(minx,maxx,Numx);
yout = zeros(1,Numx);
% imagelenagray = randi(100,1,1000);
%     txn = mapper(imagelenagray);
%     %save lenaqpsk.mat txn;
%     rcv = awgn(txn,Noise);
%     decod = demapper(rcv,size(imagelenagray,1),size(imagelenagray,2));%image comes to be rotated
%     tdecod = decod.';
%     yout(1) = BER(imagelenagray,tdecod); 
for index = 1:numel(snrx)
   imagelenagray = randi(100,1,1000);
    txn = mapper(imagelenagray);
    %save lenaqpsk.mat txn;
    rcv = awgn(txn,snrx(index));
    decod = demapper(rcv,size(imagelenagray,1),size(imagelenagray,2));%image comes to be rotated
    tdecod = decod.';
    yout(index) = BER(imagelenagray,tdecod); 
end
semilogy(snrx,yout);
%imshow(decod,[]);
%save decoded.mat decod